From 4f6bc820520d35bf9e1986f048915681b2aaeb91 Mon Sep 17 00:00:00 2001 From: Stephen Chandler Paul Date: Mon, 22 Jun 2015 18:16:27 +0200 Subject: [PATCH] Wayland: Translate wl_tablet.down/up into button events These are sent with button=GDK_BUTTON_PRIMARY, axes must be also included in these events, in addition to motion ones. --- gdk/wayland/gdkdevice-wayland.c | 64 +++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index f5653eed43..f3f0397d67 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -3133,6 +3133,66 @@ tablet_tool_handle_proximity_out (void *data, gdk_device_update_tool (tablet->current_device, NULL); } +static void +tablet_create_button_event_frame (GdkWaylandTabletData *tablet, + GdkEventType evtype, + guint button) +{ + GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat); + GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (seat->display); + GdkEvent *event; + + event = gdk_wayland_tablet_get_frame_event (tablet, evtype); + event->button.window = g_object_ref (tablet->pointer_info.focus); + gdk_event_set_device (event, tablet->master); + gdk_event_set_source_device (event, tablet->current_device); + gdk_event_set_device_tool (event, tablet->current_tool->tool); + event->button.time = tablet->pointer_info.time; + event->button.state = device_get_modifiers (tablet->master); + event->button.button = button; + gdk_event_set_screen (event, wayland_display->screen); + + get_coordinates (tablet->master, + &event->button.x, + &event->button.y, + &event->button.x_root, + &event->button.y_root); +} + +static void +tablet_tool_handle_down (void *data, + struct zwp_tablet_tool_v1 *wp_tablet_tool, + uint32_t serial) +{ + GdkWaylandTabletToolData *tool = data; + GdkWaylandTabletData *tablet = tool->current_tablet; + GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat); + GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (seat->display); + + if (!tablet->pointer_info.focus) + return; + + _gdk_wayland_display_update_serial (wayland_display, serial); + tablet->pointer_info.press_serial = serial; + + tablet_create_button_event_frame (tablet, GDK_BUTTON_PRESS, GDK_BUTTON_PRIMARY); + tablet->pointer_info.button_modifiers |= GDK_BUTTON1_MASK; +} + +static void +tablet_tool_handle_up (void *data, + struct zwp_tablet_tool_v1 *wp_tablet_tool) +{ + GdkWaylandTabletToolData *tool = data; + GdkWaylandTabletData *tablet = tool->current_tablet; + + if (!tablet->pointer_info.focus) + return; + + tablet_create_button_event_frame (tablet, GDK_BUTTON_RELEASE, GDK_BUTTON_PRIMARY); + tablet->pointer_info.button_modifiers &= ~GDK_BUTTON1_MASK; +} + static void tablet_tool_handle_motion (void *data, struct zwp_tablet_tool_v1 *wp_tablet_tool, @@ -3307,8 +3367,8 @@ static const struct zwp_tablet_tool_v1_listener tablet_tool_listener = { tablet_tool_handle_removed, tablet_tool_handle_proximity_in, tablet_tool_handle_proximity_out, - tablet_handler_placeholder, /* down */ - tablet_handler_placeholder, /* up */ + tablet_tool_handle_down, + tablet_tool_handle_up, tablet_tool_handle_motion, tablet_tool_handle_pressure, tablet_tool_handle_distance, -- 2.30.2